/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package abricots.net.common;

import abricots.command.PlayerCommand;
import abricots.command.Command;
import abricots.entity.state.BasicEntityState;
import abricots.entity.state.ControllableEntityState;
import abricots.entity.state.EntityState;
import abricots.entity.state.ServerEntityState;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryonet.Connection;
import com.esotericsoftware.kryonet.EndPoint;
import com.esotericsoftware.minlog.Log;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author charly
 */
public class NetUtils {
   public static int TCP_PORT = 4000;
   public static int UDP_PORT = 4001;
   public static int SERVER_FRAME_DURATION = 100; // A key frame twice a second

   public static void registerClasses(EndPoint endPoint) {
      Log.INFO();
      Kryo kryo = endPoint.getKryo();
      // Interfaces
      kryo.register(List.class);
      kryo.register(Command.class);
      kryo.register(EntityState.class);
      // Messages
      kryo.register(GameMessage.class);
      kryo.register(GameMessage.GameTimeSyncMessage.class);
      kryo.register(GameMessage.EntityMessage.class);
      kryo.register(GameMessage.WorldDiffMessage.class);
      kryo.register(GameMessage.CommandsMessage.class);
      // Implementations
      kryo.register(ArrayList.class);
      kryo.register(PlayerCommand.class);
      kryo.register(BasicEntityState.class);
      kryo.register(ControllableEntityState.class);
      kryo.register(ServerEntityState.class);
   }

   public interface GameClientListener {
      public void messageReceived(Object message, Connection connection);

      public void connectionFailed();

      public void onConnection(Connection connection);

      public void onDisConnection(Connection connection);
   }
}
